{% extends "base.html" %}

{% load i18n %}

{% block title %}{% trans "Dissertations"%}{% endblock %}

{% block custom_headers %}
    <script language="JavaScript" type="text/javascript">
        $(document).ready(function(){
                    // Si hay submit con errores, sub_area select toma el valor seteado (si existe)
                    var id = $('#id_area').find(':selected').val();
                    if (id) {
                        $('#id_sub_area').load('/dissertations/get_sub_areas/'+id+'/');
                        setTimeout(function(){
                            $('#id_sub_area option[value={{form.data.sub_area}}]').attr('selected', 'selected');
                            },2000)
                        }
                    // Si cambia el select Area, se generan las opciones del select SubArea
                    $('#id_area').change(function(){
                        var id = $("#id_area").find(':selected').val();
                        $('#id_sub_area').load('/dissertations/get_sub_areas/'+id+'/');
                        });
                });
    </script>
{% endblock %}

{% block head %}{% trans "Add Dissertation"%}{% endblock %}
{% block content %}
    <form method="POST" action=".">{% csrf_token %}
        <table class="formTable" align="center">
            <tr>
                <td class="formfieldleft">{{ form.date.label_tag }}<br />{{ form.date.errors }}</td>
                <td class="formfieldright">{{ form.date }}<br />{{ form.date.help_text }}</td>
            </tr>
            <tr>
                <td class="formfieldleft">{{ form.author_first_name.label_tag }}<br />{{ form.author_first_name.errors }}</td>
                <td class="formfieldright">{{ form.author_first_name }}<br />{{ form.author_first_name.help_text }}</td>
            </tr>
            <tr>
                <td class="formfieldleft">{{ form.author_last_name.label_tag }}<br />{{ form.author_last_name.errors }}</td>
                <td class="formfieldright">{{ form.author_last_name }}<br />{{ form.author_last_name.help_text }}</td>
            </tr>
            <tr>
                <td class="formfieldleft">{{ form.author_email.label_tag }}<br />{{ form.author_email.errors }}</td>
                <td class="formfieldright">{{ form.author_email }}<br />{{ form.author_email.help_text }}</td>
            </tr>
            <tr>
                <td class="formfieldleft">{{ form.author_phone.label_tag }}<br />{{ form.author_phone.errors }}</td>
                <td class="formfieldright">{{ form.author_phone }}<br />{{ form.author_phone.help_text }}</td>
            </tr>
            <tr>
                <td class="formfieldleft">{{ form.filiation.label_tag }}<br />{{ form.filiation.errors }}</td>
                <td class="formfieldright">{{ form.filiation }}<br />{{ form.filiation.help_text }}</td>
            </tr>
            <tr>
                <td class="formfieldleft">{{ form.filiation_country.label_tag }}<br />{{ form.filiation_country.errors }}</td>
                <td class="formfieldright">{{ form.filiation_country }}<br />{{ form.filiation_country.help_text }}</td>
            </tr>
            <tr>
                <td class="formfieldleft">{{ form.presenter.label_tag }}<br />{{ form.presenter.errors }}</td>
                <td class="formfieldright">{{ form.presenter }}<br />{{ form.presenter.help_text }}</td>
            </tr>
            <tr>
                <td class="formfieldleft">{{ form.main_author.label_tag }}<br />{{ form.main_author.errors }}</td>
                <td class="formfieldright">{{ form.main_author }}<br />{{ form.main_author.help_text }}</td>
            </tr>
            <tr>
                <td class="formfieldleft">{{ form.registered.label_tag }}<br />{{ form.registered.errors }}</td>
                <td class="formfieldright">{{ form.registered }}<br />{{ form.registered.help_text }}</td>
            </tr>
            <tr>
                <td class="formfieldleft">{{ form.language.label_tag }}<br />{{ form.language.errors }}</td>
                <td class="formfieldright">{{ form.language }}<br />{{ form.language.help_text }}</td>
            </tr>
            <tr>
                <td class="formfieldleft">{{ form.title.label_tag }}<br />{{ form.title.errors }}</td>
                <td class="formfieldright">{{ form.title }}<br />{{ form.title.help_text }}</td>
            </tr>
            <tr>
                <td class="formfieldleft">{{ form.dissertation.label_tag }}<br />{{ form.dissertation.errors }}</td>
                <td class="formfieldright">{{ form.dissertation }}<br />{{ form.dissertation.help_text }}</td>
            </tr>
            <tr>
                <td class="formfieldleft">{{ form.dissertation_type.label_tag }}<br />{{ form.dissertation_type.errors }}</td>
                <td class="formfieldright">{{ form.dissertation_type }}<br />{{ form.dissertation_type.help_text }}</td>
            </tr>
            <tr>
                <td class="formfieldleft">{{ form.area.label_tag }}<br />{{ form.area.errors }}</td>
                <td class="formfieldright">{{ form.area }}<br />{{ form.area.help_text }}</td>
            </tr>
            <tr>
                <td class="formfieldleft"><br />{{ form.sub_area.label_tag }}<br />{{ form.sub_area.errors }}</td>
                <td class="formfieldright">
                        <select name="sub_area" id="id_sub_area">
                        </select>
                    <br />{{ form.sub_area.help_text }}
                </td>
            </tr>
        </table><br />
        <input type="submit" value="{% trans "Add"%}" name="send" />
    </form>
    <br /><br /><br /><br /><br /><br />
{% endblock %}
 
